package Features;

import java.util.ArrayList;
import java.util.List;
import com.aliasi.tokenizer.IndoEuropeanTokenizerFactory;
import com.aliasi.tokenizer.Tokenizer;
import com.aliasi.tokenizer.TokenizerFactory;


public class FeatureNumberOfTokens extends Feature{

	static final TokenizerFactory TOKENIZER_FACTORY = IndoEuropeanTokenizerFactory.INSTANCE;
	
	public FeatureNumberOfTokens(String argumento) {
		activo = argumento.toLowerCase().contains("ntok");
	}

	public String extractSentence(String sentence){
		List<String> tokenList = new ArrayList<String>();
		List<String> whiteList = new ArrayList<String>();
		Tokenizer tokenizer = TOKENIZER_FACTORY.tokenizer(sentence.toCharArray(),0,sentence.length());
		tokenizer.tokenize(tokenList,whiteList);
		
		String[] tokens = new String[tokenList.size()];
		tokenList.toArray(tokens);
	
		int contador=0;
		for(int i=0; i<tokens.length;i++){
			if(!tokens[i].matches(".*\\p{Punct}.*")){
				contador++;
			}
		}
		return Integer.toString(contador);
	}
	
}
